#include <allFactory.h>

namespace Controller {

  View::DockIcon *AllFactory::CreateDockIcon(Model::AttackType attackType, GooCanvasItem *root)
  {
    using namespace Model;

    View::DockIcon *dockIcon;
    GdkPixbuf *bg,*mg,*fg;
    std::string bgPath, mgPath , fgPath;
    std::string confPath(VIEW_CONF_PATH);

    switch(attackType)
      {
      case SYSTEM_SETTING : {
	bgPath = confPath + "skin/default/settingBg.png";
	mgPath = confPath + "skin/default/settingMg.png";
	fgPath = confPath + "skin/default/settingFg.png";
      }break;
      case SYN_ATTACK : {
	bgPath = confPath + "skin/default/synBg.png";
	mgPath = confPath + "skin/default/synMg.png";
	fgPath = confPath + "skin/default/synFg.png";
      }break;
      case ARP_ATTACK : {
	bgPath = confPath + "skin/default/arpBg.png";
	mgPath = confPath + "skin/default/arpMg.png";
	fgPath = confPath + "skin/default/arpFg.png";
      }break;
      case SMURF_ATTACK : {
        bgPath = confPath + "skin/default/smurfBg.png";
        mgPath = confPath + "skin/default/smurfMg.png";
        fgPath = confPath + "skin/default/smurfFg.png";
      }break;
      default : return NULL;
      }

    bg = gdk_pixbuf_new_from_file(bgPath.c_str() , NULL);
    //mg = gdk_pixbuf_scale_simple(bg,120,120,GDK_INTERP_NEAREST);
    mg = gdk_pixbuf_new_from_file(mgPath.c_str() , NULL);
    fg = gdk_pixbuf_new_from_file(fgPath.c_str() , NULL);

    dockIcon = new View::DockIcon(root,0,0,bg,mg,fg);
    dockIcon->SetAttackType( attackType );

    g_object_unref(bg);
    g_object_unref(mg);
    g_object_unref(fg);

    return dockIcon;
  }

  View::SubControllItem *AllFactory::CreateSubControllItem(Model::AttackType attackType, 
							   GooCanvasItem *root)
  {
    using namespace Model;

    View::SubControllItem *subControllItem = NULL;
    switch(attackType)
      {
      case SYSTEM_SETTING : {
	subControllItem = new View::SettingSubControllItem(root) ;
      }break;
      case SYN_ATTACK : {
	subControllItem = new View::SynSubControllItem(root);
      }break;
      case ARP_ATTACK : {
	subControllItem = new View::ArpSubControllItem(root);
      }break;
      case SMURF_ATTACK :{
	subControllItem = new View::SmurfSubControllItem(root);
      }break;
      default : break;
      }

    return subControllItem;
  }

}
